import { request } from "@/utils/service"
import type {
  addContactRequestData,
  addContactResponseData,
  getContactListResponseData,
  getContactPageListResponseData,
  getContactDetailResponseData
} from "./types/contact"
import { contactData } from "@/views/crm/types/comment"

/**添加联系人 */
export function addContact(data: addContactRequestData) {
  return request<addContactResponseData>({
    url: "crm/contact",
    method: "post",
    data
  })
}

/**获取全部联系人列表 */
export function getAllContactList() {
  return request<getContactListResponseData>({
    url: "crm/contact",
    method: "get"
  })
}
/**获取分页的联系人列表 */
export function getContactPageList(params?: { page?: number; pageSize?: number }) {
  return request<getContactPageListResponseData>({
    url: "crm/contact/list",
    method: "get",
    params
  })
}

/**获取联系袭人详细信息 */
export function getContactDetail(params: { id: string }) {
  return request<getContactDetailResponseData>({
    url: "crm/contact/detail",
    method: "get",
    params
  })
}

/**修改联系人信息 */
export function updateContactDetail(data: contactData) {
  return request({
    url: "crm/contact/detail",
    method: "put",
    data
  })
}
